import { Prefab, Vec3, instantiate,Node } from "cc";


export class Block {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;
    public i : number = 0;
    public j : number = 0;
    public pos : Vec3 = null;
    public blockNodeItem : Node = null;

    public initBlock(parent:Node,prefab:Prefab,_i:number,_j:number,_p:Vec3)
    {
        this.i = _i;
        this.j = _j;
        this.pos = _p;
        this.blockNodeItem = instantiate(prefab);
        this.blockNodeItem.setPosition(this.pos);
        parent.addChild(this.blockNodeItem);
    }

    public resetBlock(_x:number,_y:number,_i:number,_j:number,newBlock : Block)
    {
        this.i = _i;
        this.j = _j;
        this.pos = new Vec3(_x,_y,0);
        this.blockNodeItem = newBlock.blockNodeItem;
        this.blockNodeItem.setPosition(this.pos);
    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
